package com.qjc.demo.chain.controller;

import com.qjc.demo.chain.handler.ChainHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 责任链模式：可以用来做参数校验，
 *
 * @ClassName: ChainController
 * @Author: qjc
 * @Date: 2023/5/10 10:53
 */
@RestController
@RequestMapping("/chain")
public class TestChainController {

    @Resource
    private ChainHandler chainHandler;

    /**
     * http://localhost:8081/chain/test?param=wewrqwe
     *
     * @param param：随意填，为空也行
     * @return
     */
    @RequestMapping("/test")
    public String testChain(@RequestParam(name = "param", required = false) String param) {
        return chainHandler.process(param);
    }

}
